package com.xyw.code.authentication.server.service;

import com.xyw.code.authentication.server.matcher.NewMvcRequestMatcher;
import com.xyw.code.authorization.common.entity.vo.SysMenu;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.web.util.matcher.RequestMatcher;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: xuyiwei
 * Date: 2020/3/2
 * Time: 下午10:03
 * Email: 1328312923@qq.com
 * Description: No Description
 **/
public interface IMenuService {

    /**
     * 动态新增更新权限
     *
     * @param resource
     */
    void saveMenu(SysMenu resource);

    /**
     * 动态删除权限
     *
     * @param resource
     */
    void removeMenu(SysMenu resource);

    /**
     * 加载权限资源数据
     */
    Map<NewMvcRequestMatcher, ConfigAttribute> loadMenu();

    /**
     * 根据url和method查询到对应的权限信息
     *
     * @param authRequest
     * @return
     */
    ConfigAttribute findConfigAttributesByUrl(HttpServletRequest authRequest);

    /**
     * 根据用户名查询 该用户所拥有的角色对应的资源信息
     *
     * @param username
     * @return
     */
    List<SysMenu> queryByUsername(String username);

}
